﻿<UserControl x:Class="Client.View.OsobaView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:converters="clr-namespace:Client.Converters"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d">

    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary  Source="pack://application:,,,/Client;component/Resources/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <converters:ComboBoxItemConverter x:Key="cboxConverter"/>
        </ResourceDictionary>

    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="1*"/>
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <ComboBox Name="cboxTypes"
                  Margin="5" 
                  ItemsSource="{Binding OsobaTypes}"
                  SelectedItem="{Binding CurrentOsobaType, Mode=TwoWay}"
                  Grid.ColumnSpan="2"
                  Grid.Row="0">
            <ComboBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock FontSize="26" Text="{Binding Converter={StaticResource cboxConverter}}"/>
                </DataTemplate>
            </ComboBox.ItemTemplate>
        </ComboBox>
        
        <ContentControl Grid.Row="1" Grid.RowSpan="10" Margin="10,5,10,5" Content="{Binding CurrentPageViewModel}" />

        <Grid Grid.Row="11">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="1*"/>
                <ColumnDefinition Width="1*"/>
            </Grid.ColumnDefinitions>
            <Button Grid.Column="0" VerticalAlignment="Stretch" Margin="2" Width="Auto" Command="{Binding CurrentPageViewModel.NewCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}}">Unos</Button>
            <Button Grid.Column="1" VerticalAlignment="Stretch" Margin="2"  Width="Auto" Command="{Binding CurrentPageViewModel.UpdateCommand}" CommandParameter="{Binding }">Izmena</Button>
            <Button Grid.Column="2" VerticalAlignment="Stretch" Margin="2"  Width="Auto" Command="{Binding CurrentPageViewModel.DeleteCommand}" CommandParameter="{Binding CurrentPageViewModel.SelectedItem}">Brisanje</Button>
        </Grid>
    </Grid>
</UserControl>
